CUBE CONNECT Edition Help

Connecting to a matrix with the CubeMatrix Class

Once a matrix file has been opened, several methods are available to investigate the content of the matrix file. The following two methods can be used to generate a CubeMatrix object from the CubeMatrixFile:

  • addMatrix(name, (dataType), (compressionLevel)), adding a new matrix inside the matrix file, with name, data type and compression level specified as arguments.
  • matrix(name or index), connecting to an existing matrix with the specified name or index.

The matrix data types are given by the below CubeMatrixDataType object. We would recommend not using numbers for the enumerated types as these numbers may change, e.g., preferable to use cp.CubeMatrixDataType_Double.

Code CubeMatrixDataType
0 Int8
1 Int16
2 Int32
3 Int64
4 Float
5 (default) Double
6 String
7 Unknown

The compression level is given by the below CubeMatrixCompressionLevel object. We would recommend not using numbers for the enumerated types as these numbers may change, e.g., preferable to use cp.CubeMatrixCompressionLevel_Level_1.

Code CubeMatrixCompressionLevel
0 (default) NoCompression
1 Level_1
2 Level_2
3 Level_3
4 Level_4
5 Level_5
6 Level_6
7 Level_7
8 Level_8
9 Level_9

The first example below shows how to add a new matrix to the matrix file, with name "new_random_matrix", data type "Double" and compression level 1.

new_matrix = mt.addMatrix("new_random_matrix", cp.CubeMatrixDataType_Double, cp.CubeMatrixCompressionLevel_Level_1)

The second example below show how to open an existing matrix instead, which name is "existing_matrix".

mat_tab = mt.matrix("existing_matrix")